#include"Stack.h"
#include"Queue.h"
void TestStack()
{
	Stack s;
	InitStack(&s);
	StackPush(&s, 1);
	StackPush(&s, 2);
	StackPush(&s, 3);
	StackPop(&s);
	StackPush(&s, 4);
	StackPush(&s, 5);
	StackPop(&s);
	while (StackIsEmpty(&s) == false)
	{
		printf("%d ", StackTop(&s));
		StackPop(&s);
	}
	printf("\n");
}
void TestQueue()
{
	Queue q;
	QueueInit(&q);
	QueuePush(&q, 1);
	QueuePush(&q, 2);
	QueuePop(&q);
	QueuePush(&q, 3);
	QueuePush(&q, 4);
	while (!QueueIsEmpty(&q))
	{
		printf("%d ", QueueFront(&q));
		QueuePop(&q);
	}
}


bool isValid(char* s) {
	Stack st;
	InitStack(&st);
	while (*s != '\0')
	{
		switch (*s)
		{
		case '(':
		case '[':
		case '{':
		{
			StackPush(&st, *s);
			s++;
			break;
		}

		case ')':
		case '}':
		case ']':
		{
			if (StackIsEmpty(&st))
			{
				DestroySTack(&st);
				return false;
			}
			char top = StackTop(&st);

			if ((*s == ')' && top != '(') ||
				(*s == '}' && top != '{') ||
				(*s == ']' && top != '['))
			{
				DestroySTack(&st);
				return false;
			}
			else
			{
				StackPop(&st);
				s++;
			}
			break;
		}
		}
	}

	return StackIsEmpty(&st);;
}
int main()
{
	TestStack();
	//TestQueue();
	/*char*s = "()";
	isValid(s);*/
	return 0;
}